unit uMain;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls;   

type
  TfMain = class(TForm)
    Timer1: TTimer;
    procedure FormCreate(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
    procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure FormDestroy(Sender: TObject);
    procedure FormPaint(Sender: TObject);
    procedure FormKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure FormMouseUp(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure FormMouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
  private
    { Private declarations }    
  public
    { Public declarations }
  end;

var
  fMain: TfMain;

implementation

uses uGraph, uScenes, uSceneGame, uUtils, uScene;

{$R *.dfm}

procedure TfMain.FormCreate(Sender: TObject);
begin
  Path := ExtractFilePath(ParamStr(0));
  Graph := TGraph.Create(Canvas, Screen.Width, Screen.Height);
  Scenes.Scene := SceneGame;
end;

procedure TfMain.Timer1Timer(Sender: TObject);
begin
  Scenes.Timer;
end;

procedure TfMain.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
  Scenes.MouseMove(X, Y);
end;

procedure TfMain.FormDestroy(Sender: TObject);
begin
  Graph.Free;  
end;

procedure TfMain.FormPaint(Sender: TObject);
begin
  Scenes.Render;
end;

procedure TfMain.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  Scenes.KeyDown(Key);
  case Key of
    13, 27: Close;
  end;
end;

procedure TfMain.FormMouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  Scenes.MouseUp(TMouseBtn(Button));
end;

procedure TfMain.FormMouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  Scenes.MouseDn(TMouseBtn(Button));
end;

end.
